package com.su.gulimall.cart.vo;


import java.math.BigDecimal;
import java.util.List;

public class Cart {

   private List<CartItem> carts;
   //一共有多少商品（每个购物项可能包含多个商品）
   private Integer countNum;
   //一共有多少购物项
   private Integer countType;
   //
   private BigDecimal totalAmount;
   //减免价格
   private BigDecimal reduce=new BigDecimal("0.00");

    public List<CartItem> getCarts() {
        return carts;
    }

    public void setCarts(List<CartItem> carts) {
        this.carts = carts;
    }

    public Integer getCountNum() {
         int count=0;
        if(carts!=null && carts.size()>0) {
            for (CartItem cart : carts) {
                 count+=cart.getCount();
            }
        }
        return count;
    }

    public Integer getCountType() {
        int count=0;
        if(carts!=null && carts.size()>0) {
            for (CartItem cart : carts) {
                count+=1;
            }
        }
        return count;
    }
    public BigDecimal getTotalAmount() {
        BigDecimal count = new BigDecimal("0");
        BigDecimal subtract=null;
        if(carts!=null && carts.size()>0)
        {

            for (CartItem cart : carts) {
                if(cart.getCheck())
                {
                    count=count.add(cart.getTotalPrice());
                }
            }
           subtract = count.subtract(getReduce());
        }

        return subtract;
    }

    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }
}
